home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / Found / FWDebug / Include / FWDbgStr.h next >
Encoding:
Text File  |  1996-04-25  |  4.3 KB  |  181 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWDbgStr.h
  4. //    Release Version:    $ ODF 1 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef FWENVDEF_H
  11. #include "FWEnvDef.h"
  12. #endif
  13.  
  14. #if !defined(FWDBGSTR_H) && defined(FW_DEBUG)
  15. #define FWDBGSTR_H
  16.  
  17. #include <stddef.h>
  18.  
  19. #ifndef FWSTDDEF_H
  20. #include "FWStdDef.h"
  21. #endif
  22.  
  23. #ifdef FW_BUILD_WIN
  24. #include <Windows.h>
  25. #endif
  26.  
  27. //========================================================================================
  28. // CLASS FW_CDebugStream
  29. //========================================================================================
  30.  
  31. class FW_CDebugStream
  32. {
  33. public:
  34.     typedef FW_CDebugStream& (*Manipulator)(FW_CDebugStream &);
  35.  
  36.     friend FW_CDebugStream& EndLine(FW_CDebugStream &);
  37.  
  38.     FW_CDebugStream();
  39.     virtual ~FW_CDebugStream();
  40.         // Destructor
  41.     
  42.     virtual FW_CDebugStream &Write(const void *data, size_t size) = 0;
  43.         // Does the raw write of the data without any data separator
  44.     
  45.     FW_CDebugStream &WriteChunk(const void *data, size_t size);
  46.         // Write raw data with a data separator
  47.  
  48.     FW_CDebugStream &operator<<(Manipulator function);
  49.         // Execute the manipulator
  50.  
  51.     
  52.     FW_CDebugStream &operator<<(const char *string);
  53.         // Write null terminated char string
  54.         
  55.     FW_CDebugStream &operator<<(const signed char *string);
  56.         // Write null terminated string
  57.         
  58.     FW_CDebugStream &operator<<(const unsigned char *string);
  59.         // Write null terminated string
  60.         
  61.  
  62.     FW_CDebugStream &operator<<(char c);
  63.         // Write character
  64.  
  65.     FW_CDebugStream &operator<<(signed char c);
  66.         // Write signed character
  67.  
  68.     FW_CDebugStream &operator<<(unsigned char c);
  69.         // Write unsigned character
  70.  
  71.     FW_CDebugStream &operator<<(short n);
  72.         // Write short
  73.  
  74.     FW_CDebugStream &operator<<(int n);
  75.         // Write int
  76.  
  77.     FW_CDebugStream &operator<<(long n);
  78.         // Write long
  79.  
  80.     FW_CDebugStream &operator<<(unsigned short n);
  81.         // Write unsigned short
  82.  
  83.     FW_CDebugStream &operator<<(unsigned n);
  84.         // Write unsigned
  85.  
  86.     FW_CDebugStream &operator<<(unsigned long n);
  87.         // Write unsigned long
  88.  
  89.     FW_CDebugStream &operator<<(void *);
  90.         // Write address in hex
  91.  
  92. protected:
  93.     FW_CDebugStream & WriteBase10Number(unsigned long n);
  94.         // Write long in base 10
  95.  
  96.     FW_CDebugStream & WriteBase16Number(unsigned long n);
  97.         // Write unsigned long in base 16
  98.  
  99. private:
  100.     FW_CDebugStream(FW_CDebugStream& debugStream);
  101.     FW_CDebugStream& operator=(FW_CDebugStream& debugStream);
  102.         // Don't copy instances of this class.
  103. };
  104.  
  105.  
  106. inline FW_CDebugStream &FW_CDebugStream::operator<<(Manipulator function)
  107. {
  108.     return function(*this);
  109. }
  110.  
  111. inline FW_CDebugStream & FW_CDebugStream::operator<<(const char *string)
  112. {
  113.     return operator<<((const signed char *) string);
  114. }
  115.  
  116. inline FW_CDebugStream & FW_CDebugStream::operator<<(const unsigned char *string)
  117. {
  118.     return operator<<((const signed char *) string);
  119. }
  120.  
  121. inline FW_CDebugStream & FW_CDebugStream::operator<<(char c)
  122. {
  123.     return operator<<((signed char) c);
  124. }
  125.  
  126. inline FW_CDebugStream & FW_CDebugStream::operator<<(unsigned char c)
  127. {
  128.     return operator<<((signed char) c);
  129. }
  130.  
  131. inline FW_CDebugStream & FW_CDebugStream::operator<<(short n)
  132. {
  133.     return operator<<((long) n);
  134. }
  135.  
  136. inline FW_CDebugStream & FW_CDebugStream::operator<<(int n)
  137. {
  138.     return operator<<((long) n);
  139. }
  140.  
  141. inline FW_CDebugStream & FW_CDebugStream::operator<<(unsigned short n)
  142. {
  143.     return operator<<((unsigned long) n);
  144. }
  145.  
  146. inline FW_CDebugStream & FW_CDebugStream::operator<<(unsigned n)
  147. {
  148.     return operator<<((unsigned long) n);
  149. }
  150.  
  151.  
  152. //========================================================================================
  153. // CLASS EndLine
  154. //========================================================================================
  155.  
  156. FW_CDebugStream&  EndLine(FW_CDebugStream &);
  157.     // Output end of line character or characters depending on platform
  158.  
  159.  
  160. #ifdef FW_BUILD_MAC
  161. //========================================================================================
  162. // CLASS FW_CMacDebugStr
  163. //========================================================================================
  164. class FW_CMacDebugStr : public FW_CDebugStream
  165. {
  166. public:
  167.     FW_CMacDebugStr();
  168.     virtual ~FW_CMacDebugStr();
  169.  
  170.     virtual FW_CDebugStream &Write(const void *data, size_t size);
  171.  
  172. private:
  173.     void Flush();
  174.  
  175. private:
  176.     unsigned char fStr255[256];
  177. };
  178. #endif
  179.  
  180. #endif
  181.